home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / tip / mocal.tip < prev    next >
Text File  |  1993-09-15  |  3KB  |  91 lines

  1. % This macro source file is from the four volume series
  2. % "TeX in Practice" by Stephan von Bechtolsheim, published
  3. % 1993 by Springer-Verlag, New York.
  4. % Copyright 1993 Stephan von Bechtolsheim.
  5. % No warranty or liability is assumed.
  6. % This macro may be copied freely if no fees other than
  7. % media cost or shipping charges are charged and as long
  8. % as this copyright and the following source code itself
  9. % is not changed. Please see the series for further information.
  10. %
  11. % Version: 1.0
  12. % Date: May 1, 1993
  13. %
  14. %
  15. % This source code is documented in 26.19, p. III-385.
  16. % Original source in file "macros6.TEX", starting line 1327.
  17. \wlog{L: "mocal.tip" ["macros6.TEX," l. 1327, p. III-385]}%
  18. % This file DOES belong to format "texip."
  19. \InputD{dateofw.tip}
  20. \InputD{doloop.tip}
  21. \InputD{arbday.tip}
  22. \InputD{nextday.tip}
  23. \InputD{numdyr.tip}
  24. \InputD{prmonth.tip}
  25. \catcode`\@ = 11
  26. \newcount\@InitialDayOfMonth
  27. \newcount\@MCDays
  28. \newcount\@MonthlyCalendarBodyTemp
  29. \def\MonthlyCalendarBody #1#2#3{%
  30.     {%
  31.         \CheckDate{#1}{#2}{1}%
  32.         \ArbitraryDayOfWeek{#1}% 
  33.             {#2}{1}{\@InitialDayOfMonth}%
  34.         \gdef #3{}%
  35.         \DoLoop{\@MonthlyCalendarBodyTemp}% 
  36.             {1}{1}{\@InitialDayOfMonth}%
  37.             {\xdef#3{#3&}}
  38.         \NumberOfDaysInMonth{#1}{#2}{\@MCDays}%
  39.         \DoLoop{\@MonthlyCalendarBodyTemp}{1}{1}{\@MCDays}{%
  40.             \xdef#3{#3\the\@MonthlyCalendarBodyTemp}%
  41.             \ifnum\@InitialDayOfMonth = \Saturday
  42.                 \xdef#3{#3\cr}%
  43.             \else
  44.                 \xdef#3{#3&}%
  45.             \fi
  46.             \advance\@InitialDayOfMonth by 1
  47.             \IModN{\@InitialDayOfMonth}{7}{\@InitialDayOfMonth}%
  48.         }%
  49.     }%
  50.     \xdef#3{#3\crcr}%
  51. }
  52. \newcount\@MonthlyCalendarCount
  53. \def\MonthlyCalendar #1#2#3{%
  54.     {%
  55.         \MonthlyCalendarBody{#1}{#2}{\TableBody}%
  56.         \vtop{
  57.             \hsize = #3\relax
  58.             \ProvideMonth{#2}{0}{\MonthNameTemp}%
  59.             \@MonthlyCalendarCount = #1\relax
  60.             \centerline{\MyStrut\MonthNameTemp\space
  61.                 \the\@MonthlyCalendarCount}%
  62.             \smallskip
  63.             \hrule
  64.             \smallskip
  65.                                 \tabskip = 0pt
  66.             \halign to \hsize{
  67.                                     % So
  68.                 \hfil##\relax   \tabskip = 0pt plus 1fil&
  69.                 \hfil##&            % Mo
  70.                 \hfil##&            % Tu
  71.                 \hfil##&            % We
  72.                 \hfil##&            % Th
  73.                 \hfil##&            % Fr
  74.                 \hfil##\relax   \tabskip = 0pt
  75.             \cr
  76.                 \omit\hfil So\hfil&
  77.                 \omit\hfil Mo\hfil&
  78.                 \omit\hfil Tu\hfil&
  79.                 \omit\hfil We\hfil&
  80.                 \omit\hfil Th\hfil&
  81.                 \omit\hfil Fr\hfil&
  82.                 \omit\hfil Sa\hfil\cr
  83.                 \TableBody
  84.             }%
  85.             \smallskip
  86.             \hrule
  87.         }%
  88.     }%
  89. }%
  90. \catcode`\@ = 12
  91.